$(function(){
    //0.自定义滚动条
    $(window).on("load",function(){
        $(".content_list").mCustomScrollbar();
    });
    $('.content_list').delegate('list_music_info','mouseenter',function(){
        //显示子菜单
        alert('傻逼？')
        $(this).find('.list_menu').stop().fadeIn(100);
        //隐藏时长
        $(this).find('.list_time span').stop().fadeOut(10);
        //显示垃圾桶
        $(this).find('.list_time a').stop().fadeIn(100);
    })
    
    //1.监听歌曲的移入移出事件
    $('.list_music>li').hover(function(){
        
    },function(){
        //隐藏子菜单
        $(this).find('.list_menu').stop().fadeOut(100);
        //隐藏垃圾桶
        $(this).find('.list_time a').stop().fadeOut(10);
        //显示时长
        $(this).find('.list_time span').stop().fadeIn(100);
    })
    // 2.监听复选框的点击事件
    $('.list_check').click(function(){
        $(this).toggleClass('list_checked');
    })
    // 3.加载歌曲列表
    getPlayerList()
    function getPlayerList(){
        $.ajax(
            {
                //url：要加载的文件地址
                url:"./source/musiclist.json",
                //dataType：文件格式
                dataType:"json",
                //加载成功之后调用success对象的回调函数
                success:function(data){
                    // 遍历获取到的数据，收集每一条音乐的信息
                    // 在HTML页面中找到音乐列表的ul之后，保存在$musicList范围内
                    var $musicList = $(".content_list ul");
                    $.each(data,function(index,ele){
                        var $item = createMusicItem(index,ele);
                        $musicList.append($item);
                    })
                },
                //加载失败之后调用error对象的回调函数
                error:function(e){
                    console.log(e)
                }
            }
        )
    }
    //定义一个方法创建一条音乐
    function createMusicItem(index,music){
        var $item = $("<li class=\"list_music_info\">" +
        "<div class=\"list_check\"><i></i></div>" +
        "<div class=\"list_number\">"+ (index+1) +"</div>" +
        "<div class=\"list_name\">"+music.name +
            "<div class=\"list_menu\">" +
                "<a href=\"javascript:;\" title=\"播放\"><svg t=\"1600429676578\" class=\"icon\"" +
                        "viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\""+
                        'p-id=\"14975\" width=\"200\" height=\"200\">' +
                        '<path' +
                            'd=\"M511.951499 1023.999903A511.951499 511.951499 0 1 1 939.982877 793.074213a27.424243 27.424243 0 0 1-45.933184-30.137596 456.32777 456.32777 0 1 0-136.34597 134.601672 27.424243 27.424243 0 1 1 29.071635 46.2239 510.110295 510.110295 0 0 1-274.823859 80.237714z\"' +
                            'p-id=\"14976\" fill=\"#ffffff\"></path>' +
                        '<path' +
                            'd=\"M392.273267 733.283549a27.521148 27.521148 0 0 1-27.424243-27.521148v-387.621805a27.521148 27.521148 0 0 1 41.184817-23.741835l335.680483 193.810902a27.424243 27.424243 0 0 1 0 47.580577l-335.680483 193.810902a27.90877 27.90877 0 0 1-13.760574 3.682407z m27.521148-367.465471v292.363747l253.310849-146.230326z\"' +
                            "p-id=\"14977\" fill=\"#ffffff\"></path>" +
                    '</svg></a>' +
                '<a href=\"javascript:;\" title=\"添加\"><svg t=\"1600429872826\" class=\"icon\"' +
                        'viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"'+
                       ' p-id=\"16385\" width=\"200\" height=\"200\">' +
                        '<path'+
                            'd=\"M512 981.333333c259.2 0 469.333333-210.133333 469.333333-469.333333S771.2 42.666667 512 42.666667 42.666667 252.8 42.666667 512s210.133333 469.333333 469.333333 469.333333z m0-42.666666C276.352 938.666667 85.333333 747.648 85.333333 512S276.352 85.333333 512 85.333333s426.666667 191.018667 426.666667 426.666667-191.018667 426.666667-426.666667 426.666667z\"p-id=\"16386\" fill=\"#ffffff\"></path>'+
                        '<path'+
                            'd=\"M298.666667 533.333333h426.666666a21.333333 21.333333 0 1 0 0-42.666666H298.666667a21.333333 21.333333 0 0 0 0 42.666666z\"'+
                            'p-id=\"16387\" fill=\"#ffffff\"></path>' +
                        '<path' +
                            'd=\"M490.666667 298.666667v426.666666a21.333333 21.333333 0 1 0 42.666666 0V298.666667a21.333333 21.333333 0 1 0-42.666666 0z\"' +
                            'p-id=\"16388\" fill=\"#ffffff\"></path>' +
                    '</svg></a>' +
                '<a href=\"javascript:;\" title=\"下载\"><svg t=\"1600429343840\" class=\"icon\"' +
                        'viewBox=\"0 0 1026 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"' +
                        'p-id=\"6471\" width=\"200\" height=\"200\">' +
                        '<path' +
                            'd=\"M1026.051533 979.552588a44.447412 44.447412 0 0 1-44.447412 44.447412H44.78943a44.447412 44.447412 0 0 1 0-89.578631h935.447078a44.447412 44.447412 0 0 1 44.447413 44.447412z m-513.538564-126.504174a44.447412 44.447412 0 0 1-44.447412-44.447412V44.789316a44.447412 44.447412 0 1 1 89.578631 0v763.811686a44.447412 44.447412 0 0 1-44.447413 44.447412z m0 0\"' +
                            'p-id=\"6472\" fill=\"#e6e6e6\"></path>' +
                        '<path' +
                            'd=\"M547.387092 840.056093a44.447412 44.447412 0 0 1-63.593989 0L144.625156 503.623372A44.447412 44.447412 0 1 1 205.483921 440.713189l341.903171 335.748915a44.447412 44.447412 0 0 1 0 63.593989z m0 0\"' +
                            'p-id=\"6473\" fill=\"#e6e6e6\"></path>'+
                        '<path d=\"M479.006458 840.056093a44.447412 44.447412 0 0 1 0-63.593989l335.748915-335.748915a44.447412 44.447412 0 1 1 63.59399 63.59399L547.387092 840.056093a44.447412 44.447412 0 0 1-63.593989 0z m0 0\"p-id=\"6474\" fill=\"#e6e6e6\"></path>' +
                    '</svg></a>' +
                "<a href=\"javascript:;\" title=\"分享\"><svg t=\"1600429427719\" class=\"icon\""+
                        'viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"p-id=\"11607\" width=\"200\" height=\"200\"><pathd=\"M911.6 651.6l0 209.2c0 36-30.4 66.2-66.2 66.2l-699.6 1.2c-35.8 0-65-29.2-65-65.2l1.2-699.6c0-35.8 30.4-66.2 66.2-66.2l387 0L535.2 20.2 148.2 20.2c-81.8 0-143 82.8-143 156.8l0 686c0 77.6 63 140.8 140.8 140.8l686 0c82 0 156.6-68.2 156.6-143L988.6 651.6 911.6 651.6 911.6 651.6zM730.2 60.8l288.6 289.2L730.2 639l0-165.2c0 0-286.4-31.8-453.6 206.6 0 0 52.6-454.4 453.6-454.4L730.2 60.8 730.2 60.8z\"p-id=\"11608\" fill=\"#e6e6e6\"></path></svg></a>'+
            '</div>' +
        '</div>' +
        '<div class=\"list_singer\">'+ music.singer +'</div>' +
        '<div class=\"list_time\">' +
            '<span>'+ music.time +'</span>' +
            '<a href=\"javascript:;\" title=\"删除\"><svg t=\"1600422069131\" class=\"icon\"viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"p-id=\"4029\" width=\"200\" height=\"200\"><pathd=\"M608 768c-17.696 0-32-14.304-32-32L576 384c0-17.696 14.304-32 32-32s32 14.304 32 32l0 352C640 753.696 625.696 768 608 768zM416 768c-17.696 0-32-14.304-32-32L384 384c0-17.696 14.304-32 32-32s32 14.304 32 32l0 352C448 753.696 433.696 768 416 768zM928 224l-160 0L768 160c0-52.928-42.72-96-95.264-96L352 64C299.072 64 256 107.072 256 160l0 64L96 224C78.304 224 64 238.304 64 256s14.304 32 32 32l832 0c17.696 0 32-14.304 32-32S945.696 224 928 224zM320 160c0-17.632 14.368-32 32-32l320.736 0C690.272 128 704 142.048 704 160l0 64L320 224 320 160zM736.128 960 288.064 960c-52.928 0-96-43.072-96-96L192.064 383.52c0-17.664 14.336-32 32-32s32 14.336 32 32L256.064 864c0 17.664 14.368 32 32 32l448.064 0c17.664 0 32-14.336 32-32L768.128 384.832c0-17.664 14.304-32 32-32s32 14.336 32 32L832.128 864C832.128 916.928 789.056 960 736.128 960z\"p-id=\"4030\" fill=\"#e6e6e6\"></path></svg></a>'+
        '</div>'+
    '</li>')
    return $item;
    }
})